const children = [
    {
        path: '/security/user',
        name: 'SecurityUser',
        component: () => import('@/views/security/user/user.vue')
    },
];
const routes = [

    //访问路由“/”,自动重定向到"/home"
    {
        path: '/',
        redirect: '/m_login'
    },
    // {
    //     path: '/login',
    //     name: 'Login',
    //     component: () => import('@/views/login.vue')
    // },
    // {
    //     path: '/register',
    //     name: 'Register',
    //     component: () => import('@/views/register.vue')
    // },
    // {
    //     path: '/home',
    //     name: 'Home',
    //     component: () => import('@/views/home/home.vue'),
    //     children: [
    //         {
    //             path: '/home/announcement',
    //             name: 'announcement',
    //             component: () => import('@/views/home/announcement.vue')
    //         },
    //         {
    //             path: '/home/releaseDeal',
    //             name: 'releaseDeal',
    //             component: () => import('@/views/home/releaseDeal.vue')
    //         },
    //         {
    //             path: '/home/personalCenter/personalInfo',
    //             name: 'personalInfo',
    //             component: () => import('@/views/home/personalCenter/personalInfo.vue')
    //         },
    //         {
    //             path: '/home/personalCenter/myRelease',
    //             name: 'myRelease',
    //             component: () => import('@/views/home/personalCenter/myRelease.vue')
    //         },
    //         {
    //             path: '/home/personalCenter/myTrading',
    //             name: 'myTrading',
    //             component: () => import('@/views/home/personalCenter/myTrading.vue')
    //         },
    //         {
    //             path: '/home/personalCenter/myDelivery',
    //             name: 'myDelivery',
    //             component: () => import('@/views/home/personalCenter/myDelivery.vue')
    //         },
    //         {
    //             path: '/home/market/energyList',
    //             name: 'energyList',
    //             component: () => import('@/views/home/market/energyList.vue')
    //         },
    //         {
    //             path: '/home/market/allRelease',
    //             name: 'allRelease',
    //             component: () => import('@/views/home/market/allRelease.vue')
    //         },
    //         {
    //             path: '/home/market/KLines',
    //             name: 'KLines',
    //             component: () => import('@/views/home/market/KLines.vue')
    //         },
    //         {
    //             path: '/home/help/referencePrice',
    //             name: 'referencePrice',
    //             component: () => import('@/views/home/help/referencePrice.vue')
    //         },
    //         {
    //             path: '/home/help/tradeDescription',
    //             name: 'tradeDescription',
    //             component: () => import('@/views/home/help/tradeDescription.vue')
    //         },
    //         {
    //             path: '/home/help/contactUs',
    //             name: 'contactUs',
    //             component: () => import('@/views/home/help/contactUs.vue')
    //         },
    //         {
    //             path: '/home/market/tradeDetail',
    //             name: 'tradeDetail',
    //             component: () => import('@/views/home/market/tradeDetail.vue')
    //         },
    //         {
    //             path: '/test',
    //             name: 'test',
    //             component: () => import('@/views/test.vue')
    //         },
    //     ]
    // },
    {
        path: '/m_login',
        name: 'M_Login',
        component: () => import('@/views/m_login.vue')
    },
    {
        path: '/m_register',
        name: 'M_Register',
        component: () => import('@/views/m_register.vue')
    },
    {
        path: '/m_home',
        name: 'M_Home',
        component: () => import('@/views/m_home/m_home.vue'),
        children: [
            {
                path: '/m_home/index',
                name: 'index',
                component: () => import('@/views/m_home/index.vue')
            },
            {
                path: '/m_home/energyManagement/createEnergy',
                name: 'createEnergy',
                component: () => import('@/views/m_home/energyManagement/createEnergy.vue')
            },
            {
                path: '/m_home/energyManagement/energyDetail',
                name: 'energyDetail',
                component: () => import('@/views/m_home/energyManagement/energyDetail.vue')
            },
            {
                path: '/m_home/userManagement/balanceManagement',
                name: 'balanceManagement',
                component: () => import('@/views/m_home/userManagement/balanceManagement.vue')
            },
            {
                path: '/m_home/userManagement/userManagement',
                name: 'userManagement',
                component: () => import('@/views/m_home/userManagement/userManagement.vue')
            },
            {
                path: '/m_home/systemSetting',
                name: 'systemSetting',
                component: () => import('@/views/m_home/systemSetting.vue')
            },
        ]
    },
    {
        path: '/404',
        name: "NotFound",
        component: () => import('@/views/404.vue')
    }
];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

export default routes;